﻿using DFGK.IService.LY;
using DFGK.Service.LY;
using DFGK_WMS.Common;
using DFGK_WMS.Model.Models.LyModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.WebAPI.Controllers.PC.装备智能采购辅助软件
{
    /// <summary>
    /// 横向采购成本分析
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiExplorerSettings(GroupName = "PC")]
    public class ProcurementCostAnalysisController : BaseController
    {
        private readonly IProcurementCostAnalysisService procurementCostAnalysis;
        public ProcurementCostAnalysisController(IWebHostEnvironment environment, IProcurementCostAnalysisService procurementCostAnalysis) : base(environment)
        {
            this.procurementCostAnalysis = procurementCostAnalysis;
        }
        /// <summary>
        /// 横向采购成本分析分页查询
        /// </summary>
        /// <param name="totalCount"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetProcurementCostAnalysis(int pageIndex = 1, int pageSize = 15)
        {
            if (pageIndex <= 0 || pageSize <= 0)
            {
                BaseResult.Result("400", "分页条件有误！");
            }
            var list = procurementCostAnalysis.GetProcurementCostAnalysis(out var totalCount, pageIndex, pageSize);
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200", totalCount));
            }
            return Ok(BaseResult.Result(null, "查询失败！", "500", 0));
        }
    }
}
